Code cells¶
This first code cells have some tags
In [1]:
Copied!
a = 1
a = 1
In [2]:
Copied!
a
a
Out[2]:
1
In [3]:
Copied!
b = 'pew'
b = 'pew'
In [4]:
Copied!
b
b
Out[4]:
'pew'
In [5]:
Copied!
import re
import re
In [6]:
Copied!
text = 'foo bar\t baz \tqux'
text = 'foo bar\t baz \tqux'
In [7]:
Copied!
re.split('\s+', text)
re.split('\s+', text)
<>:1: SyntaxWarning: invalid escape sequence '\s'
<>:1: SyntaxWarning: invalid escape sequence '\s'
/var/folders/jh/kqmryfv53533wx83vdhl_5zr0000gn/T/ipykernel_12412/1439998361.py:1: SyntaxWarning: invalid escape sequence '\s'
re.split('\s+', text)
Out[7]:
['foo', 'bar', 'baz', 'qux']
Equations¶
In [8]:
Copied!
%%latex
\begin{align}
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
\nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
\nabla \cdot \vec{\mathbf{B}} & = 0
\end{align}
%%latex \begin{align} \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\ \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\ \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\ \nabla \cdot \vec{\mathbf{B}} & = 0 \end{align}
\begin{align} \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\ \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\ \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\ \nabla \cdot \vec{\mathbf{B}} & = 0 \end{align}
Pandas DataFrames¶
In [9]:
Copied!
import numpy as np
import pandas as pd
import numpy as np import pandas as pd
In [10]:
Copied!
dates = pd.date_range('20130101', periods=6)
df = pd.DataFrame(np.random.randn(6, 4), index=dates, columns=list('ABCD'))
df
dates = pd.date_range('20130101', periods=6) df = pd.DataFrame(np.random.randn(6, 4), index=dates, columns=list('ABCD')) df
Out[10]:
| A | B | C | D | |
|---|---|---|---|---|
| 2013-01-01 | 0.085060 | -1.267770 | 0.521208 | 0.611831 |
| 2013-01-02 | 0.214535 | -0.471671 | -0.132712 | 0.905061 |
| 2013-01-03 | 0.909726 | -0.190264 | -1.101087 | 0.287650 |
| 2013-01-04 | 1.958348 | -0.023132 | 0.321645 | 0.055242 |
| 2013-01-05 | -2.046925 | 0.284635 | -0.503192 | -0.278366 |
| 2013-01-06 | 1.390397 | -1.219210 | -0.388945 | 1.193144 |
Plots¶
In [11]:
Copied!
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
In [12]:
Copied!
from pylab import *
from pylab import *
In [13]:
Copied!
x = linspace(0, 5, 10)
y = x ** 2
x = linspace(0, 5, 10) y = x ** 2
This is some text, here comes some latex
bokeh¶
In [16]:
Copied!
from bokeh.plotting import figure, output_notebook, show
from bokeh.plotting import figure, output_notebook, show
In [18]:
Copied!
p = figure()
p.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], line_width=2)
show(p)
p = figure() p.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], line_width=2) show(p)
plotly¶
This requires a theme modification to include Require.JS
In [19]:
Copied!
import plotly.express as px
import plotly.express as px
In [20]:
Copied!
df = px.data.iris()
fig = px.scatter(df, x="sepal_width", y="sepal_length")
fig.show()
df = px.data.iris() fig = px.scatter(df, x="sepal_width", y="sepal_length") fig.show()
Widgets¶
In [21]:
Copied!
import ipywidgets as widgets
import ipywidgets as widgets
In [22]:
Copied!
widget = widgets.IntSlider(
value=7,
min=0,
max=10,
step=1,
description='',
disabled=False,
continuous_update=False,
orientation='horizontal',
readout=True,
readout_format='d'
)
value_lbl = widgets.Label()
widgets.jslink((widget, 'value'), (value_lbl, 'value'))
display(widget, widgets.HBox([widgets.Label("Current Value:"), value_lbl]) )
widget = widgets.IntSlider( value=7, min=0, max=10, step=1, description='', disabled=False, continuous_update=False, orientation='horizontal', readout=True, readout_format='d' ) value_lbl = widgets.Label() widgets.jslink((widget, 'value'), (value_lbl, 'value')) display(widget, widgets.HBox([widgets.Label("Current Value:"), value_lbl]) )